/**
 * 
 */
package cn.edu.nju.ws.sview.wyge.listener;

import java.sql.SQLException;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import cn.edu.nju.ws.sview.wyge.relations.index.SearchIndexManager;

/**
 * @author Weiyi Ge (geweiyi@gmail.com) 2012-7-19
 * 
 */
public class IndexListener implements ServletContextListener {
	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.
	 * ServletContextEvent)
	 */
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		// TODO Auto-generated method stub
//		IndexManager.getIndexManager().closeAll();
		SearchIndexManager.getIndexManager().closeAll();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * javax.servlet.ServletContextListener#contextInitialized(javax.servlet
	 * .ServletContextEvent)
	 */
	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		// TODO Auto-generated method stub
		try {
//			IndexManager.getIndexManager().initialize("fromTomcat");
			SearchIndexManager.getIndexManager().initialize("fromTomcat");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
